package com.qingcheng.service.impl;

import com.qingcheng.service.goods.CategoryService;
import com.qingcheng.service.goods.SkuService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: LDeng
 * @Date: 2020-05-21 15:29
 */


//该类继承InitializingBean 接口 ， 随着工程启动的时候启动

@Component
public class Init implements InitializingBean{

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private SkuService skuService;

    public void afterPropertiesSet() throws Exception {

        System.out.println("============》init() 分类数据存入redis缓存《=============");
        categoryService.saveCategoryTreeToRedis();
        System.out.println("============》init() SKU数据存入redis缓存《=============");
        skuService.saveAllPriceToRedis();
    }
}
